<?php
/**
 * Library Of Shared Code (LOSC)
 *
 * LICENSE
 *
 * This source file is subject to the New BSD License that is bundled
 * with this package in the file LICENSE.txt.
 *
 * @category   LOSC Framework
 * @package    View
 * @subpackage Helper
 * @copyright  Copyright (c) 2008 Robin Skoglund (http://robinsk.net/)
 * @license    http://creativecommons.org/licenses/BSD/  New BSD License
 */

/**
 * View helper for retrieving application options
 *
 * @category   LOSC Framework
 * @package    View
 * @subpackage Helper
 * @copyright  Copyright (c) 2008 Robin Skoglund (http://robinsk.net/)
 * @license    http://creativecommons.org/licenses/BSD/  New BSD License
 */
class Losc_View_Helper_Options
{
    /**
     * Options instance
     *
     * @var Losc_App_Options
     */
    protected $_options;
    
    /**
     * Crates view helper instance
     *
     */
    public function __construct()
    {
        $this->_options = Losc_App_Options::getInstance();
    }
    
    /**
     * Proxy calls to the Losc_App_Options instance
     *
     * @param  string $name
     * @param  array  $args
     * @return array
     */
    public function __call($name, $args)
    {
        return call_user_func_array(array($this->_options, $name, $args));
    }
    
    /**
     * Returns the option with the given $name, or helper instance if $name is
     * not given
     *
     * @param  string $name       [optional] name of option to return
     * @param  string $namespace  [optional] option namespace
     * @return mixed
     */
    public function options($name = null, $namespace = null)
    {
        if (!$name) {
            return $this;
        }
        
        return $this->_options->get($name, $namespace);
    }
}
